<template>
  <el-table
    :data="tableData"
    style="width: 100%"
    :header-cell-style="{ backgroundColor: '#fafafa', color: '#909399' }"
  >
    <el-table-column prop="number" label="试题编号" width="100px">
    </el-table-column>
    <el-table-column prop="subject" label="学科" width="100px">
    </el-table-column>
    <el-table-column prop="catalog" label="目录" width="100px">
    </el-table-column>
    <el-table-column prop="questionType" label="题型" width="100px">
      <template #default="{ row }">{{ getQuestionType(row) }}</template>
    </el-table-column>
    <el-table-column label="题干" width="230px">
      <template slot-scope="scope">
        <div v-html="scope.row.question"></div>
      </template>
    </el-table-column>
    <el-table-column prop="addDate" label="录入时间" width="180px">
    </el-table-column>
    <el-table-column prop="difficulty" label="难度">
      <template #default="{ row }">{{ getDifficultyType(row) }}</template>
    </el-table-column>
    <el-table-column
      prop="creator"
      label="录入人"
      width="120px"
    ></el-table-column>

    <el-table-column
      prop="chkState"
      label="审核状态"
      width="120px"
      v-if="type === 'choice'"
    >
      <template #default="{ row }">{{ getChkType(row) }}</template>
    </el-table-column>
    <el-table-column
      prop="chkRemarks"
      label="审核意见"
      width="120px"
      v-if="type === 'choice'"
    >
    </el-table-column>
    <el-table-column
      prop="chkUser"
      label="审核人"
      width="120px"
      v-if="type === 'choice'"
    >
    </el-table-column>
    <el-table-column
      prop="publishState"
      label="发布状态"
      width="150px"
      v-if="type === 'choice'"
    >
      <template #default="{ row }">{{ getPublishType(row) }}</template>
    </el-table-column>

    <el-table-column label="操作" width="200px" fixed="right" align="center">
      <template slot-scope="scope">
        <slot name="operation" :row="scope.row"></slot>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import {
  difficulty,
  questionType,
  chkType,
  publishType
} from '@/api/hmmm/constants.js'
export default {
  name: '',
  props: { tableData: Array, type: String },

  components: {},
  data () {
    return {}
  },
  methods: {
    // 难度
    getDifficultyType (row) {
      let text
      difficulty.forEach(item => {
        if (item.value === +row.questionType) {
          text = item.difficulty
        }
      })
      return text
    },
    // 题型
    getQuestionType (row) {
      let text
      questionType.forEach(item => {
        if (item.value === +row.questionType) {
          text = item.label
        }
      })
      return text
    },
    // 审核状态
    getChkType (row) {
      let text
      chkType.forEach(item => {
        if (item.value === +row.chkState) {
          text = item.label
        }
      })
      return text
      // const text = chkType.find(el => el.value === +row.chkState).label
      // console.log(text, 1)
    },
    // 上架状态
    getPublishType (row) {
      let text
      publishType.forEach(item => {
        if (item.value === +row.publishState) {
          text = item.label
        }
      })
      return text
    }
  },
  mounted () {},
  watch: {},
  computed: {},
  filters: {},
  created () {}
}
</script>

<style scoped lang="less"></style>
